package com.cos.consumer.controller;

import com.netflix.discovery.EurekaClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author: COS
 * @time: 2022/4/27 14:16
 * @description:
 */
//@RestController
//@RequestMapping("/con")
public class ConsumerOldController {
    /**
     *
     * @author: COS
     * @return:
     * @time: 2022/4/27 14:25
     * @description:  http请求和响应的发送接受工具 (非常简单且粗暴)
     */
    @Autowired
    private RestTemplate restTemplate;
    @Resource
    private EurekaClient eurekaClient;
    @GetMapping("/findData")
    public String findDate(){
//        InstanceInfo info = eurekaClient.getNextServerFromEureka("SUPPLIER", false);
//        System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++");
//        System.out.println(info.getHomePageUrl());
//        System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++");
//        String forObject = restTemplate.getForObject(info.getHomePageUrl() + "/sup/getData", String.class);
        String forObject = restTemplate.getForObject("http://SUPPLIER/sup/getData", String.class);
        return "找到你了===>"+forObject;
    }

}
